package com.wms_backend.config;

import com.wms_backend.security.UserDetailsImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.GenericToStringSerializer;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.security.core.userdetails.UserDetails;

//@Configuration
public class RedisConfig {

    @Bean
    public RedisTemplate<String, UserDetailsImpl> redisTemplate(RedisConnectionFactory connectionFactory) {
        RedisTemplate<String, UserDetailsImpl> redisTemplate = new RedisTemplate<>();
        redisTemplate.setConnectionFactory(connectionFactory);
        redisTemplate.setValueSerializer(new Jackson2JsonRedisSerializer<>(UserDetailsImpl.class));
        return redisTemplate;
    }
}